package com.llcbenwu.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author lilinchun
 * @date 2021/10/22 0022 11:32
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {


    @Bean
    public Docket petApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.llcbenwu")) //指定提供接口所在的基包
                .build();
    }

    /**
     * 该套 API 说明，包含作者、简介、版本、host、服务URL
     * @return
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("v1.0")
                .contact(new Contact("Llc","null","https://blog.csdn.net/L1569850979?spm=1010.2135.3001.5113"))
                .version("0.1")
                .termsOfServiceUrl("http://localhost:8080/doc.html")
                .description("版本测试swagger")
                .build();
    }

}
